import axios from 'axios'

export const CHANGE_LOGIN = 'CHANGE_LOGIN'
export const loginAction = (account, password) => {
  return (dispatch) => {
    axios.get(`/api/login.json?account=${account}&password=${password}`).then((res) => {
      const result = res.data.data
      if (result) {
        dispatch({
          type: CHANGE_LOGIN,
          value: true
        })
      } else {
        alert('登录失败')
      }
    })
  }
}

export const CHANGE_LOGOUT = 'CHANGE_LOGOUT'
export const logoutAction = () => ({
  type: CHANGE_LOGOUT,
  value: false
})
